﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace PominaScale
{
    public partial class FrmDatabase : Form
    {
        public FrmDatabase()
        {
            InitializeComponent();

            btnOK.Click += new EventHandler(delegate
            {
                define.SERVER = this.edtServer.Text;
                define.DATABASE = this.edtDatabase.Text;
                define.WINDOWMODE = this.rdoWindowMode.Checked;

                if (!define.WINDOWMODE)
                {
                    define.USERID = this.edtUsername.Text;
                    define.PASSWORD = this.edtPassword.Text;
                }

                this.DialogResult = DialogResult.OK;
                this.Close();
            });

            btnExit.Click += new EventHandler(delegate
            {
                Application.Exit();
            });

            this.rdoWindowMode.CheckedChanged += new EventHandler(CheckedChanged);
            this.rdoSQLMode.CheckedChanged += new EventHandler(CheckedChanged);
        }

        void CheckedChanged(object sender, EventArgs e)
        {
            if (this.rdoWindowMode.Checked)
            {
                this.uiGroupBox1.Enabled = false;
            }
            else
            {
                this.uiGroupBox1.Enabled = true;
            }
        }

        protected override void OnLoad(EventArgs e)
        {
            edtDatabase.Text = "Pomina";
            edtServer.Text = Environment.UserDomainName + "\\SQLEXPRESS";
        }

    }
}

